package com.sky.mapper;

import com.sky.annotation.AutoFill;
import com.sky.dto.CategoryDTO;
import com.sky.dto.CategoryPageQueryDTO;
import com.sky.entity.Category;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface CategoryMapper {
    //分类分页
    List<Category> findList(CategoryPageQueryDTO categoryPageQueryDTO);

    //新增分类
    @AutoFill("insert")
    @Insert("insert into sky_take_out.category values (null,#{type},#{name},#{sort},#{status},#{createTime},#{updateTime},#{createUser},#{updateUser})")
    void save(Category category);

    //主键删除
    @Delete("delete from sky_take_out.category where id = #{id}")
    void deleteByid(Long id);

    //分类回显
    @Select("select * from sky_take_out.category where id = #{id}")
    Category findById(Long id);

    //分类修改
    @AutoFill("update")
    void update(Category category);

    //查询分类列表
    List<Category> findByStatusAndType(CategoryDTO categoryDTO);
}
